<template>
	<view>
		<uni-nav-bar title="我的理财" background-color="#FE6735" color="#FFF" :statusBar="true" :fixed="true"
			:border="false" left-icon="back" @clickLeft="$tab.back()"></uni-nav-bar>

		<view class="px-20">
			<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :fixed="false">
				<view class="bg-FFF round-24 px-24 py-32 mt-24 relative" v-for="(item,index) in list" :key="item.id">
					<image :src="`https://file.fulewanjia.com/fulewanjia/profile/appImages/${item.state == 0 ? 'img_weiwanchegn@2x' : 'img_yiwancheng@2x'}.png`" mode="" class="stateImg"></image>
					<view class="text-32 font-700">
						{{item.name}}
					</view>
					<view class="mt-24 flex items-center justify-between" style="padding-right: 142rpx;">
						<view class="">
							<view class="text-40 font-700" style="color: #FE6735;">
								{{item.perRate}}
							</view>
							<view class="text-24 text-9E9E9E">
								投资利率
							</view>
						</view>

						<view class="">
							<view class="text-40 font-700">
								{{item.validTime}}天
							</view>
							<view class="text-24 text-9E9E9E">
								{{item.startPrice}}起投 | 中低风险
							</view>
						</view>
					</view>

					<view class="mt-32 p-16" style="background-color: #FFEDDA;">
						<view class="flex items-center justify-between">
							<view class="text-9E9E9E">
								有效期：
							</view>
							<view class="">
								{{item.startTime}} 至 {{item.endTime}}
							</view>
						</view>
						<view class="flex items-center justify-between mt-16">
							<view class="text-9E9E9E">
								购买数量：
							</view>
							<view class="">
								{{item.payPrice}}
							</view>
						</view>
						<view class="flex items-center justify-between mt-16">
							<view class="text-9E9E9E">
								预计收益：
							</view>
							<view class="" style="color: #FE6735;">
								{{item.duePrice}}
							</view>
						</view>

					</view>
				</view>
			</s-pull-scroll>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
			};
		},
		onLoad() {
			this.refresh()
		},
		methods:{
			refresh() {
				this.$nextTick(() => {
					this.$refs.pullScroll.refresh();
				});
			},
			pullDown(pullScroll) {
				setTimeout(() => {
					this.loadData(pullScroll);
				}, 200);
			},
			loadData(pullScroll) {
				setTimeout(async () => {
					if (pullScroll.page == 1) {
						this.list = [];
					}
					const curList = await this.$Api.currency.financialProductsBuyList({
						pageNum: 10,
						pageSize: pullScroll.page
					})
			
					this.list = this.list.concat(curList.rows || []);
			
					if (curList.total == 0) {
						pullScroll.empty()
					}
			
					if (this.list.length >= curList.total) {
						pullScroll.finish();
					} else {
						pullScroll.success();
					}
				}, 500);
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F8F8F8;
	}
	
	.stateImg{
		position: absolute;
		right: 0;
		top: 0;
		width: 136rpx;
		height: 130rpx;
	}
</style>